package cn.jobstart.spider.pipeline;

import cn.jobstart.common.SpringUtils;
import cn.jobstart.enums.HtmlTypeFleEnum;
import cn.jobstart.enums.TalentSubscriptionTaskChannelEnum;
import cn.jobstart.es.service.IResumeEsService;
import cn.jobstart.spider.model.TalentJob51;
import cn.jobstart.spider.parsing.IParsing;
import cn.jobstart.spider.parsing.TalentJob51Parsing;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;

/**
 * @author sunke
 * @version 1.0
 * @Description 51job人才数据入库
 * @date 2023-10-23 17:26
 */
public class TalentJob51HtmplPipline extends HtmlPipline {



    private IParsing parsing;





    @Override
    public TalentJob51HtmplPipline setParsing(IParsing parsing) {
        this.parsing = parsing;
        return this;
    }

    @Override
    public int getChannelFlag() {
        return TalentSubscriptionTaskChannelEnum.JOB51.getType();
    }

    @Override
    public int getTypeFlag() {
        return HtmlTypeFleEnum.Talent.getType();
    }

    /**
     * Process extracted results.
     *
     * @param resultItems resultItems
     * @param task        task
     */
    @Override
    public void process(ResultItems resultItems, Task task) {

        TalentJob51 talentJob51 = resultItems.get("talentJob");

        if (parsing == null) {
            parsing = new TalentJob51Parsing(null);
        }
        getResumeEsService().insertAll(parsing.parsing(talentJob51));

        //    System.out.println(talentJob51);

    }
}
